/*
ID: icerupt1
PROG: ride
LANG: C++11
*/

#include <fstream>
#include <string>
using namespace std;

int calc(string s)
{
	int p = 1;
	for (auto i : s) p *= (i - 'A' + 1);
	return p;
}

int main()
{
	ofstream fout ("ride.out");
	ifstream fin ("ride.in");
	string s1, s2;
	fin >> s1 >> s2;
	if (calc(s1)%47 == calc(s2)%47)
		fout << "GO" << endl;
	else
		fout << "STAY" << endl;
}


